home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / taito_b.c < prev    next >
C/C++ Source or Header  |  2000-05-25  |  23KB  |  1,051 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4. unsigned char *taitob_fscroll;
  5. unsigned char *taitob_bscroll;
  6. unsigned char *b_backgroundram;
  7. size_t b_backgroundram_size;
  8. unsigned char *b_foregroundram;
  9. size_t b_foregroundram_size;
  10. unsigned char *b_textram;
  11. size_t b_textram_size;
  12.  
  13.  
  14. unsigned char video_control;
  15.  
  16.  
  17. static unsigned char *text_dirty;
  18. static unsigned char *bg_dirty;
  19. static unsigned char *fg_dirty;
  20. size_t b_paletteram_size;
  21.  
  22. static struct osd_bitmap *tmpbitmap2;
  23. static struct osd_bitmap *tmpbitmap3;
  24.  
  25.  
  26. unsigned char *taitob_pixelram;
  27. static struct osd_bitmap *pixel_layer;
  28.  
  29.  
  30.  
  31. WRITE_HANDLER( taitob_video_control_w )
  32. {
  33.     int val = (data>>8)&0xff;
  34.  
  35. /*
  36. * tetrist:
  37. * 0x8f - ???
  38. * 0xcf - ???
  39. * 0xaf - display lower part of pixel layer
  40. * 0xef - display upper part of pixel_layer
  41. *
  42. * crimec:
  43. * 0xef - display upper part of pixel layer
  44. * 0x28 - don't display  pixel layer (or maybe diplay the other part of it ???)
  45. *        (but continue displaying the background, foreground, text, sprites)
  46. * 0x29 - set just before enabling pixel layer
  47. *        (note that the game doesn't clear the pixel layer between enabling and
  48. *         disabling it, it just writes 0x29 here instead)
  49. * 0x20 - set at the third level (in the garage)
  50. *        (disable what ?)
  51. */
  52.  
  53.  
  54.     if ( ((video_control & 1)==0) && ((val & 1)==1) ) /*kludge*/
  55.     {
  56.         fillbitmap(pixel_layer, Machine->pens[0x800], NULL);
  57.     }
  58.  
  59. #if 0
  60.     if (val != video_control)
  61.     {
  62.         usrintf_showmessage("video control = %02x",val);
  63.     }
  64. #endif
  65.     video_control = val;
  66.  
  67. }
  68.  
  69. READ_HANDLER( tetrist_pixelram_r )
  70. {
  71.     return READ_WORD(&taitob_pixelram[offset]);
  72. }
  73.  
  74. WRITE_HANDLER( tetrist_pixelram_w )
  75. {
  76.     int sx,sy,color;
  77.  
  78.     if ( (offset&1) == 0)
  79.     {
  80.         COMBINE_WORD_MEM(&taitob_pixelram[offset],data);
  81.  
  82.         sx = (offset) & 0x1ff;
  83.         sy = (offset >> 9);
  84.  
  85.         color = READ_WORD(&taitob_pixelram[offset]);
  86.  
  87.         plot_pixel(pixel_layer, sx  , sy, Machine->pens[0x400 + ((color>>8) & 0xff)]);
  88.         plot_pixel(pixel_layer, sx+1, sy, Machine->pens[0x400 + (color & 0xff)]);
  89.     }
  90.     else
  91.     {
  92.         logerror("pixelram write to odd address\n");
  93.         /*usrintf_showmessage("write to odd address");*/
  94.     }
  95. }
  96.  
  97.  
  98. WRITE_HANDLER( crimec_pixelram_w )
  99. {
  100.     int sx,sy,color;
  101.  
  102.     if ( (offset&1) == 0)
  103.     {
  104.         COMBINE_WORD_MEM(&taitob_pixelram[offset],data);
  105.  
  106.         sx = (offset) & 0x1ff;
  107.         sy = (offset >> 9);
  108.  
  109.         color = READ_WORD(&taitob_pixelram[offset]);
  110.  
  111.         plot_pixel(pixel_layer, sx  , sy, Machine->pens[0x800 + ((color>>8) & 0xff)]);
  112.         plot_pixel(pixel_layer, sx+1, sy, Machine->pens[0x800 + (color & 0xff)]);
  113.     }
  114.     else
  115.     {
  116.         logerror("pixelram write to odd address\n");
  117.         /*usrintf_showmessage("write to odd address");*/
  118.     }
  119. }
  120.  
  121.  
  122.  
  123. int taitob_vh_start (void)
  124. {
  125.  
  126.     text_dirty = malloc (b_textram_size/2);
  127.     if (!text_dirty) return 1;
  128.     memset(text_dirty,1,b_textram_size/2);
  129.  
  130.     bg_dirty = malloc (b_backgroundram_size/4);
  131.     if (!bg_dirty)
  132.     {
  133.         free (text_dirty);
  134.         return 1;
  135.     }
  136.     memset (bg_dirty,1,b_backgroundram_size/4);
  137.  
  138.     fg_dirty = malloc (b_foregroundram_size/4);
  139.     if (!fg_dirty)
  140.     {
  141.         free (text_dirty);
  142.         free (bg_dirty);
  143.         return 1;
  144.     }
  145.     memset (fg_dirty,1,b_foregroundram_size/4);
  146.  
  147.     /* create a temporary bitmap slightly larger than the screen for the background */
  148.     if ((tmpbitmap = osd_create_bitmap(64*16, 64*16)) == 0)
  149.     {
  150.         free (text_dirty);
  151.         free (bg_dirty);
  152.         free (fg_dirty);
  153.         return 1;
  154.     }
  155.  
  156.     /* create a temporary bitmap slightly larger than the screen for the foreground */
  157.     if ((tmpbitmap2 = osd_create_bitmap(64*16, 64*16)) == 0)
  158.     {
  159.         free (text_dirty);
  160.         free (bg_dirty);
  161.         free (fg_dirty);
  162.         osd_free_bitmap (tmpbitmap);
  163.         return 1;
  164.     }
  165.  
  166.     /* create a temporary bitmap slightly larger than the screen for the text layer */
  167.     if ((tmpbitmap3 = osd_create_bitmap(64*8, 64*8)) == 0)
  168.     {
  169.         free (text_dirty);
  170.         free (bg_dirty);
  171.         free (fg_dirty);
  172.         osd_free_bitmap (tmpbitmap);
  173.         osd_free_bitmap (tmpbitmap2);
  174.         return 1;
  175.     }
  176.  
  177.     pixel_layer = osd_create_bitmap (512, 512);
  178.  
  179.     if (!pixel_layer)
  180.     {
  181.         free (text_dirty);
  182.         free (bg_dirty);
  183.         free (fg_dirty);
  184.         osd_free_bitmap (tmpbitmap);
  185.         osd_free_bitmap (tmpbitmap2);
  186.         osd_free_bitmap (tmpbitmap3);
  187.         return 1;
  188.     }
  189.  
  190.     {
  191.         int i;
  192.  
  193.         memset (paletteram, 0, b_paletteram_size); /* probably not needed */
  194.         for (i = 0; i < b_paletteram_size/2; i++)
  195.             palette_change_color (i,i*3,i*5,i*7); /*random colors*/
  196.     }
  197.  
  198.     return 0;
  199. }
  200.  
  201. /*unsigned char *b_rom;*/
  202. void taitob_vh_stop (void)
  203. {
  204. #if 0
  205. FILE *f1;
  206. FILE *f2;
  207. int i,j;
  208.     f1 = fopen("rom0o.bin","wb");
  209.     f2 = fopen("rom0e.bin","wb");
  210.     if (f1)
  211.     {
  212.         for (i=0; i<0x40000; i+=2)
  213.         {
  214.             fputc(b_rom[i + 0], f1 );
  215.             fputc(b_rom[i + 1], f2 );
  216.         }
  217.     }
  218.     fclose(f1);
  219.     fclose(f2);
  220. #endif
  221.     free (text_dirty);
  222.     free (bg_dirty);
  223.     free (fg_dirty);
  224.     osd_free_bitmap (tmpbitmap);
  225.     osd_free_bitmap (tmpbitmap2);
  226.     osd_free_bitmap (tmpbitmap3);
  227.     osd_free_bitmap (pixel_layer);
  228. }
  229.  
  230.  
  231. READ_HANDLER ( taitob_text_r )
  232. {
  233.     return READ_WORD(&b_textram[offset]);
  234. }
  235.  
  236. WRITE_HANDLER( taitob_text_w )
  237. {
  238.     int oldword = READ_WORD (&b_textram[offset]);
  239.     int newword = COMBINE_WORD (oldword, data);
  240.  
  241.     if (oldword != newword)
  242.     {
  243.         WRITE_WORD (&b_textram[offset],newword);
  244.         text_dirty[offset / 2] = 1;
  245.     }
  246. }
  247.  
  248. READ_HANDLER ( taitob_background_r )
  249. {
  250.     return READ_WORD(&b_backgroundram[offset]);
  251. }
  252. WRITE_HANDLER( taitob_background_w )
  253. {
  254.     int oldword = READ_WORD (&b_backgroundram[offset]);
  255.     int newword = COMBINE_WORD (oldword, data);
  256.  
  257.     if (oldword != newword)
  258.     {
  259.         WRITE_WORD (&b_backgroundram[offset],newword);
  260.         bg_dirty[(offset&0x1fff) / 2] = 1;
  261.     }
  262. }
  263.  
  264. READ_HANDLER ( taitob_foreground_r )
  265. {
  266.     return READ_WORD(&b_foregroundram[offset]);
  267. }
  268. WRITE_HANDLER( taitob_foreground_w )
  269. {
  270.     int oldword = READ_WORD (&b_foregroundram[offset]);
  271.     int newword = COMBINE_WORD (oldword, data);
  272.  
  273.     if (oldword != newword)
  274.     {
  275.         WRITE_WORD (&b_foregroundram[offset],newword);
  276.         fg_dirty[(offset&0x1fff) / 2] = 1;
  277.     }
  278. }
  279.  
  280. void taitob_update_palette (void)
  281. {
  282.     int i;
  283.     int offs,color;
  284.     unsigned int palette_map[256];
  285.  
  286.  
  287.     palette_init_used_colors();
  288.  
  289.     memset(palette_map, 0, sizeof(palette_map));
  290.  
  291.     /* Background layer */
  292.     for (offs = 0;offs < b_backgroundram_size/2;offs += 2)
  293.     {
  294.         int tile;
  295.  
  296.         tile = READ_WORD (&b_backgroundram[offs]) & 0x0fff;
  297.         color = 0xc0 + (READ_WORD (&b_backgroundram[offs+0x2000]) & 0x3f);
  298.  
  299.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  300.     }
  301.  
  302.     /* Foreground layer */
  303.     for (offs = 0;offs < b_foregroundram_size/2;offs += 2)
  304.     {
  305.         int tile;
  306.  
  307.         tile = READ_WORD (&b_foregroundram[offs]) & 0x0fff;
  308.         color = 0x80 + (READ_WORD (&b_foregroundram[offs+0x2000]) & 0x3f);
  309.  
  310.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  311.     }
  312.  
  313.     /* Sprites */
  314.     for (offs = 0;offs < 0x1980;offs += 16)
  315.     {
  316.         int tile;
  317.  
  318.         tile = READ_WORD(&videoram[offs]) & 0x1fff;
  319.         color = 0x40 + (READ_WORD(&videoram[offs+2]) & 0x00ff);
  320.  
  321.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  322.     }
  323.  
  324.     /* Do the text layer */
  325.     for (offs = 0; offs < 0x1000; offs += 2)
  326.     {
  327.         int tile;
  328.  
  329.         tile = READ_WORD (&b_textram[offs]);
  330.         color = (tile>>12) & 0x0f;
  331.         tile &= 0x0fff;
  332.  
  333.         palette_map[color] |= Machine->gfx[0]->pen_usage[tile];
  334.     }
  335.  
  336.     /* Tell MAME about the color usage */
  337.     for (color = 0; color < 256; color++)
  338.     {
  339.         int usage = palette_map[color];
  340.  
  341.         if (usage)
  342.         {
  343.             if (palette_map[color] & (1 << 0))
  344.                 palette_used_colors[ color * 16 + 0] = PALETTE_COLOR_TRANSPARENT;
  345.             for (i = 1; i < 16; i++)
  346.                 if (palette_map[color] & (1 << i))
  347.                     palette_used_colors[ color * 16 + i] = PALETTE_COLOR_USED;
  348.         }
  349.     }
  350.  
  351.     if (palette_recalc ())
  352.     {
  353.         memset (text_dirty, 1, b_textram_size/2);
  354.         memset (bg_dirty, 1, b_backgroundram_size/4);
  355.         memset (fg_dirty, 1, b_foregroundram_size/4);
  356.     }
  357. }
  358.  
  359. void crimec_update_palette (void)
  360. {
  361.     int i;
  362.     int offs,color;
  363.     unsigned int palette_map[256];
  364.  
  365.  
  366.     palette_init_used_colors();
  367.  
  368.     memset(palette_map, 0, sizeof(palette_map));
  369.  
  370.     /* Background layer */
  371.     for (offs = 0;offs < b_backgroundram_size/2;offs += 2)
  372.     {
  373.         int tile;
  374.  
  375.         tile = READ_WORD (&b_backgroundram[offs]) & 0x0fff;
  376.         color = 0x00 + (READ_WORD (&b_backgroundram[offs+0x2000]) & 0x3f);
  377.  
  378.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  379.     }
  380.  
  381.     /* Foreground layer */
  382.     for (offs = 0;offs < b_foregroundram_size/2;offs += 2)
  383.     {
  384.         int tile;
  385.  
  386.         tile = READ_WORD (&b_foregroundram[offs]) & 0x0fff;
  387.         color = 0x40 + (READ_WORD (&b_foregroundram[offs+0x2000]) & 0x3f);
  388.  
  389.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  390.     }
  391.  
  392.     /* Sprites */
  393.     for (offs = 0;offs < 0x1980;offs += 16)
  394.     {
  395.         int tile;
  396.  
  397.         tile = READ_WORD(&videoram[offs]) & 0x1fff;
  398.         color = 0x80 + (READ_WORD(&videoram[offs+2]) & 0x00ff);
  399.  
  400.         palette_map[color] |= Machine->gfx[1]->pen_usage[tile];
  401.     }
  402.  
  403.     /* Do the text layer */
  404.     for (offs = 0; offs < 0x1000; offs += 2)
  405.     {
  406.         int tile;
  407.  
  408.         tile = READ_WORD (&b_textram[offs]);
  409.         color = 0xc0 + ((tile>>12) & 0x0f);
  410.         tile &= 0x0fff;
  411.  
  412.         palette_map[color] |= Machine->gfx[0]->pen_usage[tile];
  413.     }
  414.  
  415.     /* Tell MAME about the color usage */
  416.     for (color = 0; color < 256; color++)
  417.     {
  418.         int usage = palette_map[color];
  419.  
  420.         if (usage)
  421.         {
  422.             if (palette_map[color] & (1 << 0))
  423.                 palette_used_colors[ color * 16 + 0] = PALETTE_COLOR_TRANSPARENT;
  424.             for (i = 1; i < 16; i++)
  425.                 if (palette_map[color] & (1 << i))
  426.                     palette_used_colors[ color * 16 + i] = PALETTE_COLOR_USED;
  427.         }
  428.     }
  429.  
  430.     if (palette_recalc ())
  431.     {
  432.         memset (text_dirty, 1, b_textram_size/2);
  433.         memset (bg_dirty, 1, b_backgroundram_size/4);
  434.         memset (fg_dirty, 1, b_foregroundram_size/4);
  435.     }
  436. }
  437.  
  438. void taitob_draw_sprites (struct osd_bitmap *bitmap)
  439. {
  440.     /*
  441.         Sprite format:
  442.         0000: 000xxxxxxxxxxxxx: tile code (0x0000 - 0x1fff)
  443.         0002: 00000000xxxxxxxx: color (0x00 - 0xff)
  444.               x000000000000000: flipy
  445.               0x00000000000000: flipx
  446.               00??????00000000: unknown
  447.         0004: xxxxxxxx xxxxxxxx: x-coordinate 16 bits signed
  448.         0006: xxxxxxxx xxxxxxxx: y-coordinate 16 bits signed
  449.         0008 - 000f : unused?
  450.  
  451.     */
  452.     int x,y,xlatch=0,ylatch=0,x_no=0,y_no=0,x_num=0,y_num=0,big_sprite=0;
  453.     int data,offs,code,color,flipx,flipy;
  454.     unsigned int zoomx, zoomy, zoomxlatch=0, zoomylatch=0;
  455.  
  456.     for (offs = 0x1980-16; offs >=0; offs -= 16)
  457.     {
  458.  
  459.         code = READ_WORD(&videoram[offs]) & 0x1fff;
  460.         if (!code) continue;
  461.  
  462.         color = READ_WORD(&videoram[offs+2]);
  463.         flipx = color & 0x4000;
  464.         flipy = color & 0x8000;
  465.  
  466.         color = 0x40 + (color & 0xff);
  467.  
  468.         x = READ_WORD(&videoram[offs+4]);
  469.         y = READ_WORD(&videoram[offs+6]);
  470.  
  471.         if (x>0x8000)
  472.             x -= 65536;
  473.         if (y>0x8000)
  474.             y -= 65536;
  475.  
  476.         data = READ_WORD(&videoram[offs+0x0a]);
  477.         if (data)
  478.         {
  479.             if (!big_sprite)
  480.             {
  481.                 x_num = (data>>8) & 0xff;
  482.                 y_num = (data) & 0xff;
  483.                 x_no  = 0;
  484.                 y_no  = 0;
  485.                 xlatch = x;
  486.                 ylatch = y;
  487.                 data = READ_WORD(&videoram[offs+0x08]);
  488.                 zoomxlatch = (data>>8) & 0xff;
  489.                 zoomylatch = (data) & 0xff;
  490.                 big_sprite = 1;
  491.             }
  492.         }
  493.  
  494.         data = READ_WORD(&videoram[offs+0x08]);
  495.         zoomx = (data>>8) & 0xff;
  496.         zoomy = (data) & 0xff;
  497.  
  498.         if (big_sprite)
  499.         {
  500.             zoomx = zoomxlatch;
  501.             zoomy = zoomylatch;
  502.  
  503.             x = xlatch + x_no*16;
  504.             y = ylatch + y_no*16;
  505.             y_no++;
  506.             if (y_no>y_num)
  507.             {
  508.                 y_no = 0;
  509.                 x_no++;
  510.                 if (x_no>x_num)
  511.                     big_sprite = 0;
  512.             }
  513.         }
  514.  
  515.  
  516.         if ( (zoomx!=0) || (zoomy!=0) )
  517.         {
  518.             //logerror("1.zoomx=%8x zoomy=%8x\n",zoomx,zoomy);
  519.             if (zoomx==0)
  520.             {
  521.                 zoomx = (1<<16);
  522.             }
  523.             else
  524.             {
  525.                 zoomx = (0x100 - zoomx);    /*1 to 255*/
  526.                 zoomx = ((zoomx/16)+1)<<12;
  527.             }
  528.  
  529.             if (zoomy==0)
  530.             {
  531.                 zoomy = (1<<16);
  532.             }
  533.             else
  534.             {
  535.                 zoomy = (0x100 - zoomy);
  536.                 zoomy = ((zoomy/16)+1)<<12;
  537.             }
  538.  
  539.             //logerror("2.zoomx=%8x zoomy=%8x\n",zoomx,zoomy);
  540.             /*temporarily disabled - caused Mame to crash :(*/
  541.         #if 0
  542.             drawgfxzoom (bitmap,Machine->gfx[1],
  543.                 code,
  544.                 color,
  545.                 flipx,flipy,
  546.                 x,y,
  547.                 0,TRANSPARENCY_PEN,palette_transparent_pen,zoomx,zoomy);
  548.         #endif
  549.             drawgfx (bitmap,Machine->gfx[1],
  550.                 code,
  551.                 color,
  552.                 flipx,flipy,
  553.                 x,y,
  554.                 0,TRANSPARENCY_PEN,0);
  555.         }
  556.         else
  557.         {
  558.             drawgfx (bitmap,Machine->gfx[1],
  559.                 code,
  560.                 color,
  561.                 flipx,flipy,
  562.                 x,y,
  563.                 0,TRANSPARENCY_PEN,0);
  564.         }
  565.     }
  566. }
  567.  
  568. void crimec_draw_sprites (struct osd_bitmap *bitmap)
  569. {
  570.     /*
  571.         Sprite format:
  572.         0000: 000xxxxxxxxxxxxx: tile code (0x0000 - 0x1fff)
  573.         0002: 00000000xxxxxxxx: color (0x00 - 0xff)
  574.               x000000000000000: flipy
  575.               0x00000000000000: flipx
  576.               00??????00000000: unused ?
  577.         0004: xxxxxxxxxxxxxxxx: x-coordinate 16 bits signed (all zero for big sprites)
  578.         0006: xxxxxxxxxxxxxxxx: y-coordinate 16 bits signed (all zero for big sprites)
  579.  
  580.  
  581.         0008: ????????!!!!!!!!: sprite zoom level
  582.               ??? and !!! are usualy the same (x scale and y scale ?)
  583.  
  584.         sprite zoom is used at the end of the third level (in the garage)
  585.         where there are four columns on the sides of the screen
  586.  
  587.  
  588.         000a: xxxxxxxx00000000: x-sprites number (big sprite)
  589.               00000000xxxxxxxx: y-sprites number (big sprite)
  590.  
  591.         000c - 000f: unused ???
  592.     */
  593.  
  594.     int x,y,xlatch=0,ylatch=0,x_no=0,y_no=0,x_num=0,y_num=0,big_sprite=0;
  595.     int data,offs,code,color,flipx,flipy;
  596.     unsigned int zoomx, zoomy, zoomxlatch=0, zoomylatch=0;
  597.  
  598.     for (offs = 0x1980-16; offs >= 0; offs -= 16)
  599.     {
  600.  
  601.         code = READ_WORD(&videoram[offs]) & 0x1fff;
  602.         /*if (!code) continue;*/
  603.  
  604.  
  605.         color = READ_WORD(&videoram[offs+2]);
  606.         flipx = color & 0x4000;
  607.         flipy = color & 0x8000;
  608.  
  609.         color = 0x80 + (color & 0xff);
  610.  
  611.         x = READ_WORD(&videoram[offs+4]);
  612.         y = READ_WORD(&videoram[offs+6]);
  613.         if (x>0x8000)
  614.             x -= 65536;
  615.         if (y>0x8000)
  616.             y -= 65536;
  617.  
  618.         data = READ_WORD(&videoram[offs+0x0a]);
  619.         if (data)
  620.         {
  621.             if (!big_sprite)
  622.             {
  623.                 x_num = (data>>8) & 0xff;
  624.                 y_num = (data) & 0xff;
  625.                 x_no  = 0;
  626.                 y_no  = 0;
  627.                 xlatch = x;
  628.                 ylatch = y;
  629.                 data = READ_WORD(&videoram[offs+0x08]);
  630.                 zoomxlatch = (data>>8) & 0xff;
  631.                 zoomylatch = (data) & 0xff;
  632.                 big_sprite = 1;
  633.             }
  634.         }
  635.  
  636.         data = READ_WORD(&videoram[offs+0x08]);
  637.         zoomx = (data>>8) & 0xff;
  638.         zoomy = (data) & 0xff;
  639.  
  640.         if (big_sprite)
  641.         {
  642.             zoomx = zoomxlatch;
  643.             zoomy = zoomylatch;
  644.  
  645.             x = xlatch + x_no*16;
  646.             y = ylatch + y_no*16;
  647.             y_no++;
  648.             if (y_no>y_num)
  649.             {
  650.                 y_no = 0;
  651.                 x_no++;
  652.                 if (x_no>x_num)
  653.                     big_sprite = 0;
  654.             }
  655.         }
  656.  
  657.  
  658.         if ( (zoomx!=0) || (zoomy!=0) )
  659.         {
  660.             //logerror("1.zoomx=%8x zoomy=%8x\n",zoomx,zoomy);
  661.             if (zoomx==0)
  662.             {
  663.                 zoomx = (1<<16);
  664.             }
  665.             else
  666.             {
  667.                 zoomx = (0x100 - zoomx);    /*1 to 255*/
  668.                 zoomx = ((zoomx/16)+1)<<12;
  669.             }
  670.  
  671.             if (zoomy==0)
  672.             {
  673.                 zoomy = (1<<16);
  674.             }
  675.             else
  676.             {
  677.                 zoomy = (0x100 - zoomy);
  678.                 zoomy = ((zoomy/16)+1)<<12;
  679.             }
  680.  
  681.             //logerror("2.zoomx=%8x zoomy=%8x\n",zoomx,zoomy);
  682.             /*temporarily disabled - caused Mame to crash :(*/
  683.         #if 0
  684.             drawgfxzoom (bitmap,Machine->gfx[1],
  685.                 code,
  686.                 color,
  687.                 flipx,flipy,
  688.                 x,y,
  689.                 0,TRANSPARENCY_PEN,palette_transparent_pen,zoomx,zoomy);
  690.         #endif
  691.             drawgfx (bitmap,Machine->gfx[1],
  692.                 code,
  693.                 color,
  694.                 flipx,flipy,
  695.                 x,y,
  696.                 0,TRANSPARENCY_PEN,0);
  697.         }
  698.         else
  699.         {
  700.             drawgfx (bitmap,Machine->gfx[1],
  701.                 code,
  702.                 color,
  703.                 flipx,flipy,
  704.                 x,y,
  705.                 0,TRANSPARENCY_PEN,0);
  706.         }
  707.     }
  708. }
  709.  
  710. void taitob_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  711. {
  712.     int offs;
  713.     int scrollx, scrolly;
  714.  
  715.  
  716.     taitob_update_palette();
  717.  
  718.     /* Do the background layer */
  719.     scrollx = READ_WORD(&taitob_bscroll[0]);
  720.     scrolly = READ_WORD(&taitob_bscroll[2]);
  721.  
  722.  
  723.     for (offs = 0;offs < b_backgroundram_size/2;offs += 2)
  724.     {
  725.         int tile, color;
  726.  
  727.         tile = READ_WORD (&b_backgroundram[offs]) & 0x0fff;
  728.         color = 0xc0 + (READ_WORD (&b_backgroundram[offs+0x2000]) & 0x003f);
  729.  
  730.         if (bg_dirty[offs/2])
  731.         {
  732.             int sx,sy;
  733.  
  734.             bg_dirty[offs/2] = 0;
  735.  
  736.             sy = (offs/2) / 64;
  737.             sx = (offs/2) % 64;
  738.  
  739.             drawgfx(tmpbitmap,Machine->gfx[1],
  740.                 tile,
  741.                 color,
  742.                 0,0,
  743.                 16*sx,16*sy,
  744.                 0,TRANSPARENCY_NONE,0);
  745.         }
  746.     }
  747.  
  748.     copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  749.  
  750.  
  751.     /* Do the foreground layer */
  752.     scrollx = READ_WORD(&taitob_fscroll[0]);
  753.     scrolly = READ_WORD(&taitob_fscroll[2]);
  754.  
  755.     for (offs = 0;offs < b_foregroundram_size/2;offs += 2)
  756.     {
  757.         int tile, color;
  758.  
  759.         tile = READ_WORD (&b_foregroundram[offs]) & 0x0fff;
  760.         color = 0x80 + (READ_WORD (&b_foregroundram[offs+0x2000]) & 0x003f);
  761.  
  762.         if (fg_dirty[offs/2])
  763.         {
  764.             int sx,sy;
  765.  
  766.  
  767.             fg_dirty[offs/2] = 0;
  768.  
  769.             sy = (offs/2) / 64;
  770.             sx = (offs/2) % 64;
  771.  
  772.             drawgfx(tmpbitmap2,Machine->gfx[1],
  773.                 tile,
  774.                 color,
  775.                 0,0,
  776.                 16*sx,16*sy,
  777.                 0,TRANSPARENCY_NONE,0);
  778.         }
  779.     }
  780.     copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  781.  
  782.  
  783.     taitob_draw_sprites (bitmap);
  784.  
  785.  
  786.     for (offs = 0;offs < 0x1000;offs += 2)
  787.     {
  788.         if (text_dirty[offs/2] )
  789.         {
  790.             int sx,sy;
  791.             int tile, color;
  792.  
  793.             tile  = READ_WORD (&b_textram[offs]);
  794.             color = (tile>>12) & 0x0f;
  795.             tile &= 0x0fff;
  796.  
  797.             text_dirty[offs/2] = 0;
  798.  
  799.             sy = (offs/2) / 64;
  800.             sx = (offs/2) % 64;
  801.  
  802.             drawgfx(tmpbitmap3,Machine->gfx[0],
  803.                 tile,
  804.                 color,
  805.                 0,0,
  806.                 8*sx,8*sy,
  807.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  808.         }
  809.     }
  810.     copybitmap(bitmap,tmpbitmap3,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  811.  
  812. }
  813.  
  814. void crimec_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  815. {
  816.     int offs;
  817.     int scrollx, scrolly;
  818.  
  819.  
  820.     crimec_update_palette();
  821.  
  822.     /* Do the background layer */
  823.     scrollx = READ_WORD(&taitob_bscroll[0]);
  824.     scrolly = READ_WORD(&taitob_bscroll[2]);
  825.  
  826.  
  827.     for (offs = 0;offs < b_backgroundram_size/2;offs += 2)
  828.     {
  829.         int tile, color;
  830.  
  831.         tile = READ_WORD (&b_backgroundram[offs]) & 0x0fff;
  832.         color = 0x00 + (READ_WORD (&b_backgroundram[offs+0x2000]) & 0x003f);
  833.  
  834.         if (bg_dirty[offs/2])
  835.         {
  836.             int sx,sy;
  837.  
  838.             bg_dirty[offs/2] = 0;
  839.  
  840.             sy = (offs/2) / 64;
  841.             sx = (offs/2) % 64;
  842.  
  843.             drawgfx(tmpbitmap,Machine->gfx[1],
  844.                 tile,
  845.                 color,
  846.                 0,0,
  847.                 16*sx,16*sy,
  848.                 0,TRANSPARENCY_NONE,0);
  849.         }
  850.     }
  851.  
  852.     copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  853.  
  854.     /* Do the foreground layer */
  855.     scrollx = READ_WORD(&taitob_fscroll[0]);
  856.     scrolly = READ_WORD(&taitob_fscroll[2]);
  857.  
  858.     for (offs = 0;offs < b_foregroundram_size/2;offs += 2)
  859.     {
  860.         int tile, color;
  861.  
  862.         tile = READ_WORD (&b_foregroundram[offs]) & 0x0fff;
  863.         color = 0x40 + (READ_WORD (&b_foregroundram[offs+0x2000]) & 0x003f);
  864.  
  865.         if (fg_dirty[offs/2])
  866.         {
  867.             int sx,sy;
  868.  
  869.  
  870.             fg_dirty[offs/2] = 0;
  871.  
  872.             sy = (offs/2) / 64;
  873.             sx = (offs/2) % 64;
  874.  
  875.             drawgfx(tmpbitmap2,Machine->gfx[1],
  876.                 tile,
  877.                 color,
  878.                 0,0,
  879.                 16*sx,16*sy,
  880.                 0,TRANSPARENCY_NONE,0);
  881.         }
  882.     }
  883.     copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  884.  
  885.     if (video_control==0xef) /*a HACK !*/
  886.         copybitmap(bitmap,pixel_layer,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_PEN,Machine->pens[0x800]);
  887.  
  888.  
  889.     crimec_draw_sprites (bitmap);
  890.  
  891.  
  892.     for (offs = 0;offs < 0x1000;offs += 2)
  893.     {
  894.         if (text_dirty[offs/2] )
  895.         {
  896.             int sx,sy;
  897.             int tile, color;
  898.  
  899.             tile  = READ_WORD (&b_textram[offs]);
  900.             color = 0xc0 + ((tile>>12) & 0x0f);
  901.             tile &= 0x0fff;
  902.  
  903.             text_dirty[offs/2] = 0;
  904.  
  905.             sy = (offs/2) / 64;
  906.             sx = (offs/2) % 64;
  907.  
  908.             drawgfx(tmpbitmap3,Machine->gfx[0],
  909.                 tile,
  910.                 color,
  911.                 0,0,
  912.                 8*sx,8*sy,
  913.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  914.         }
  915.     }
  916.     copybitmap(bitmap,tmpbitmap3,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  917.  
  918. }
  919.  
  920. void tetrist_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  921. {
  922.     /*int offs;*/
  923.     int scrollx, scrolly;
  924.  
  925.     /*crimec_update_palette();*/
  926.  
  927.     switch ( (video_control>>6) & 3 )
  928.     {
  929.     /*is the highest bit - pixel layer enable ? */
  930.  
  931.     case 0: /* 00xx xxxx */
  932.         break;
  933.  
  934.     case 1: /* 01xx xxxx */
  935.         break;
  936.  
  937.     case 2: /* 10xx xxxx */
  938.         scrollx = 0;
  939.         scrolly = 256;
  940.         copyscrollbitmap(bitmap,pixel_layer,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  941.         break;
  942.  
  943.     case 3: /* 11xx xxxx */
  944.         scrollx = 0;
  945.         scrolly = 0;
  946.         copyscrollbitmap(bitmap,pixel_layer,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  947.         break;
  948.     }
  949.  
  950. #if 0
  951.     /* Do the background layer */
  952.     scrollx = READ_WORD(&taitob_bscroll[0]);
  953.     scrolly = READ_WORD(&taitob_bscroll[2]);
  954.  
  955.     for (offs = 0;offs < b_backgroundram_size/2;offs += 2)
  956.     {
  957.         int tile, color;
  958.  
  959.         tile = READ_WORD (&b_backgroundram[offs]) & 0x0fff;
  960.         color = 0x00 + (READ_WORD (&b_backgroundram[offs+0x2000]) & 0x003f);
  961.  
  962.         if (bg_dirty[offs/2])
  963.         {
  964.             int sx,sy;
  965.  
  966.             bg_dirty[offs/2] = 0;
  967.  
  968.             sy = (offs/2) / 64;
  969.             sx = (offs/2) % 64;
  970.  
  971.             drawgfx(tmpbitmap,Machine->gfx[1],
  972.                 tile,
  973.                 color,
  974.                 0,0,
  975.                 16*sx,16*sy,
  976.                 0,TRANSPARENCY_NONE,0);
  977.         }
  978.     }
  979.  
  980.     copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  981. #endif
  982.  
  983. #if 0
  984.     /* Do the foreground layer */
  985.     scrollx = READ_WORD(&taitob_fscroll[0]);
  986.     scrolly = READ_WORD(&taitob_fscroll[2]);
  987.  
  988.     for (offs = 0;offs < b_foregroundram_size/2;offs += 2)
  989.     {
  990.         int tile, color;
  991.  
  992.         tile = READ_WORD (&b_foregroundram[offs]) & 0x0fff;
  993.         color = 0x40 + (READ_WORD (&b_foregroundram[offs+0x2000]) & 0x003f);
  994.  
  995.         if (fg_dirty[offs/2])
  996.         {
  997.             int sx,sy;
  998.  
  999.  
  1000.             fg_dirty[offs/2] = 0;
  1001.  
  1002.             sy = (offs/2) / 64;
  1003.             sx = (offs/2) % 64;
  1004.  
  1005.             drawgfx(tmpbitmap2,Machine->gfx[1],
  1006.                 tile,
  1007.                 color,
  1008.                 0,0,
  1009.                 16*sx,16*sy,
  1010.                 0,TRANSPARENCY_NONE,0);
  1011.         }
  1012.     }
  1013.     copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  1014. #endif
  1015.  
  1016. #if 0
  1017.     crimec_draw_sprites (bitmap);
  1018. #endif
  1019.  
  1020.  
  1021. #if 0
  1022.     for (offs = 0;offs < 0x1000;offs += 2)
  1023.     {
  1024.         if (text_dirty[offs/2] )
  1025.         {
  1026.             int sx,sy;
  1027.             int tile, color;
  1028.  
  1029.             tile  = READ_WORD (&b_textram[offs]);
  1030.             color = 0xc0 + ((tile>>12) & 0x0f);
  1031.             tile &= 0x0fff;
  1032.  
  1033.             text_dirty[offs/2] = 0;
  1034.  
  1035.             sy = (offs/2) / 64;
  1036.             sx = (offs/2) % 64;
  1037.  
  1038.             drawgfx(tmpbitmap3,Machine->gfx[0],
  1039.                 tile,
  1040.                 color,
  1041.                 0,0,
  1042.                 8*sx,8*sy,
  1043.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  1044.         }
  1045.     }
  1046.     copybitmap(bitmap,tmpbitmap3,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  1047. #endif
  1048.  
  1049. }
  1050.  
  1051.